package cn.seapon.talkerserver.common;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;


/** 
 * 返回个人面板信息
 * @author 作者 E-mail: 
 * @version 创建时间：2014年12月28日 下午9:51:45 
 * 类说明 
 */
public class UserInformation implements Serializable{
	//账号
	private String account = "";
	//昵称
	private String nickname = "";
	//签名
	private String signature = "";
	private String phone = "";
	private String email = "";
	private String avatar = "";
	// 生日、地区、出生地等信息可拓展
	
	


	public JSONObject getJSONObject(){
		JSONObject jsonObject = new JSONObject();
		try {
			jsonObject.put("account", account);
			jsonObject.put("nickname", nickname);
			jsonObject.put("signature", signature);
			jsonObject.put("phone", phone);
			jsonObject.put("email", email);
			jsonObject.put("avatar", avatar);
		} catch (JSONException e) {
			e.printStackTrace();
			return null;
		}
		return jsonObject;
	}
	
	public static UserInformation getObjectFromJson(JSONObject jsonObject){
		UserInformation information = new UserInformation();
		try {
			String account = jsonObject.getString("account");
			String nickname = jsonObject.getString("nickname");
			String signature = jsonObject.getString("signature");
			String phone = jsonObject.getString("phone");
			String email = jsonObject.getString("email");
			String avatar = jsonObject.getString("avatar");
			
			information.setAccount(account);
			information.setEmail(email);
			information.setNickname(nickname);
			information.setPhone(phone);
			information.setSignature(signature);
			information.setAvatar(avatar);
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return information;
	}
	
	public String getJSONString() {
		JSONObject jsonObject = getJSONObject();
		return jsonObject.toString();
	}
	public UserInformation() {
	}
	
	public UserInformation(String account, String nickname, String signature,String phone, String email) {
		this.account = account;
		this.nickname = nickname;
		this.signature = signature;
		this.phone = phone;
		this.email = email;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getSignature() {
		return signature;
	}

	public void setSignature(String signature) {
		this.signature = signature;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}


}
